//
//  HomepageViewController.m
//  EcologyME
//
//  Created by 王旭阳 on 2017/7/19.
//  Copyright © 2017年 xzcysoft. All rights reserved.
//

#import "HomepageViewController.h"
#import "HomepageView.h"
#import "LeeSetFunctionViewController.h"//设置
#import "XiTongXiaoXiXQViewController.h"//消息
#import "SystemMessageViewController.h"//消息
#import "RechargeViewController.h"//财务
#import "NameAuthenticationViewController.h"
#import "ShenHeShiBaiViewController.h"
#import "ShenHeTongGuoViewController.h"
#import "ShenHeZhongViewController.h"
#import "LeeSKViewController.h"//收款
#import "asdfasdfViewController.h"///阿萨德法师打发
#import "ShenHeShiBaiViewController.h"
#import "LeeShoppingShenHeZhongViewController.h"//审核中
#import "LeeShoppingShenHeShiBaiViewController.h"//审核失败

@interface HomepageViewController (){
    HomepageView *homepageView;
}

@end

@implementation HomepageViewController
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden=YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIImageView*bgIV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, width_screen, height_screen)];
    bgIV.image = [UIImage imageNamed:@"bg"];
    [self.view addSubview:bgIV];
    homepageView = [[HomepageView alloc]initWithFrame:CGRectMake(0, 0, width_screen, height_screen)];
    [self.view addSubview:homepageView];
    
    
    homepageView.nameLab.text = @"小铺李四";
    [self addButton];
}
-(void)addButton{
    NSArray*imgArr = @[@"sk",@"xx",@"rz",@"cw",@"sz"];
    float distance = (width_screen-50-73)/2.0;
    for (int i=0; i<5; i++) {
        UIButton*btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(25+distance*(i%3), 237+distance*(i/3), 73, 73);
        btn.tag = 10+i;
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [btn setBackgroundImage:[UIImage imageNamed:imgArr[i]] forState:0];
        [homepageView addSubview:btn];
    }
}
-(void)btnClick:(UIButton*)btn{
    LeeSetFunctionViewController *shezhi =[LeeSetFunctionViewController new];
    XiTongXiaoXiXQViewController *xiaoxi = [XiTongXiaoXiXQViewController new];
    RechargeViewController *caiwu = [RechargeViewController new];
    LeeSKViewController *shoukuan = [LeeSKViewController new];
    asdfasdfViewController *sd = [asdfasdfViewController new];
    ShenHeShiBaiViewController *shenheshibai = [ShenHeShiBaiViewController new];
    LeeShoppingShenHeZhongViewController *shangpushenhezhong = [LeeShoppingShenHeZhongViewController new];
    LeeShoppingShenHeShiBaiViewController *shanghushenheshibai = [LeeShoppingShenHeShiBaiViewController new];
    SystemMessageViewController *xitongxiaoxi = [SystemMessageViewController new];
    NSLog(@"%ld",(long)btn.tag);
    switch (btn.tag) {
        case 10:
            [self.navigationController pushViewController:shoukuan animated:YES];
            break;
        case 11:
            [self.navigationController pushViewController:xitongxiaoxi animated:YES];
            break;
        case 12:
          [self.navigationController pushViewController:sd animated:YES];
            break;
        case 13:
              [self.navigationController pushViewController:caiwu animated:YES];
            break;
        case 14:
            
            [self.navigationController pushViewController:shezhi animated:YES];
            
            break;
            
        default:
            break;
    }
}
-(void)asdfasdf{
    NSString *url = [NSString stringWithFormat:@"%@%@",LINK_BASE_URL(@"/member/getMemberData.api?access_token="),NSUD_Obj(@"token")];
    [HTTPURL postRequest:url parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@",responseObject);
      NSDictionary *  dataDic=[PublicTools dictionaryWithJsonString:responseObject[@"data"]];
        NSLog(@"%@",dataDic);
//        [juhuaLod removeFromSuperview];
        
        //未操作
        if ([dataDic[@"status"] isEqualToString:@""]) {
            NameAuthenticationViewController*vc=[NameAuthenticationViewController new];
            vc.hidesBottomBarWhenPushed=YES;
            [self.navigationController pushViewController:vc animated:YES];
            
        }
        //                //审核通过
        if ([dataDic[@"status"] isEqualToString:@"1"]) {
            ShenHeTongGuoViewController*vc=[ShenHeTongGuoViewController new];
            vc.hidesBottomBarWhenPushed=YES;
            [self.navigationController pushViewController:vc animated:YES];
        }
        //审核失败
        if ([dataDic[@"status"] isEqualToString:@"2"]) {
            ShenHeShiBaiViewController*vc=[ShenHeShiBaiViewController new];
            vc.hidesBottomBarWhenPushed=YES;
            [self.navigationController pushViewController:vc animated:YES];
        }
        //审核中
        if ([dataDic[@"status"] isEqualToString:@"3"]) {
            ShenHeZhongViewController*vc=[ShenHeZhongViewController new];
            vc.hidesBottomBarWhenPushed=YES;
            [self.navigationController pushViewController:vc animated:YES];
        }
    } filure:^(NSURLSessionDataTask *task, id error) {
        NSLog(@"%@",error);
//        [juhuaLod removeFromSuperview];
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
